package com.lsh.airticket.controller.admin;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lsh.airticket.dto.OrderInfo;
import com.lsh.airticket.dto.Result;
import com.lsh.airticket.service.OrderService;
import com.lsh.airticket.util.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lsh
 * @date 2021/2/20
 **/
@RestController
// @CrossOrigin
@RequestMapping("/orders")
public class AdminOrderController {

    @Autowired
    OrderService orderService;

    @GetMapping("/admin/order/findOrderPage")
    public Result findAll(Integer page) {
        if (page == null || page == 0) page = 1;
        PageHelper.startPage(page, Constants.PAGE_SIZE);
        PageInfo<OrderInfo> pageInfo = orderService.findAll();
        return Result.result().addData("pageInfo", pageInfo);
    }
}
